package com.ty.day3.collection;

import java.util.ArrayList;
import java.util.Iterator;


/**
 * Created by IntelliJ IDEA.
 *
 * @author : txy
 * @create : 2023/11/24 16:46
 */
public class ArrayListDemo02 {
    public static void main(String[] args) {
        ArrayList<Cat> cats = new ArrayList<>();
        for (int i = 1; i <= 5; i++) {
            Cat cat = new Cat("唐小宇0" + i, 21 + i);
            cats.add(cat);
        }
        for (Cat cat : cats) {
            cat.print();
        }
    }
}
class Cat{
    String name;
    Integer age;
    public Cat(String name, Integer age) {
        this.name = name;
        this.age = age;
    }
    public void print(){
        System.out.println(name+"已经"+age+"岁");
    }
}

